﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace de.codingfreaks.libs.cfDateTime.EventArgs
{
    /// <summary>
    /// Used in events that report errors.
    /// </summary>
    public class ErrorOccuredEventArgs : EventArgs
    {

        #region constructor

        /// <summary>
        /// Default constructor.
        /// </summary>
        /// <param name="excThis">The exception if one caused this error.</param>
        /// <param name="strMessage">A string containing any message to the caller.</param>
        public ErrorOccuredEventArgs(Exception excThis,
                                     string strMessage)
        {
            ExceptionObject = excThis;
            if (string.IsNullOrEmpty(strMessage) &&
                excThis != null)
            {
                // lets take the exceptions message because there is no other defined
                Message = excThis.Message;
            }
            else
            {
                Message = strMessage;
            }
            DoNotThrowException = false;
        }

        #endregion

        #region properties

        /// <summary>
        /// The <c>Exception</c> which caused this error or null if it wasn't caused by an exception.
        /// </summary>
        public Exception ExceptionObject { get; private set; }

        /// <summary>
        /// A string containing informations on the error.
        /// </summary>
        public string Message { get; private set; }

        /// <summary>
        /// Indicates, if the sender should raise any exception afterwars.
        /// </summary>
        public bool DoNotThrowException { get; set; }

        #endregion

    }
}
